﻿using AutoMapper;
using MediatR;
using Traceability.App.Applications.Command.DeepProce;
using Traceability.Domain.Entity;
using Traceability.Domain.Repository;
using Traceability.Enum;

namespace Traceability.App.Applications.CommandHand.DeepProce
{
    public class UpdataDeepCommandHand : IRequestHandler<UpdataDeepCommand, ApiResult<int>>
    {

        private readonly IBaseRepository<DeepProcessingModel> _deep;
        private readonly IMapper mapper;

        public UpdataDeepCommandHand(IBaseRepository<DeepProcessingModel> deep, IMapper mapper)
        {
            _deep = deep;
            this.mapper = mapper;
        }

        public Task<ApiResult<int>> Handle(UpdataDeepCommand request, CancellationToken cancellationToken)
        {
            var result = new ApiResult<int>();
            var deep=mapper.Map<DeepProcessingModel>(request);

            _deep.Update(deep);
            return  Task.FromResult(result);
        }
    }
}
